package fina2.dcs.security;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Embeddable;

@Embeddable
@SuppressWarnings("serial")
public class UserPermissionPk implements Serializable {
	private BigDecimal userId;
	private BigDecimal permissionId;

	public UserPermissionPk() {

	}

	public UserPermissionPk(BigDecimal userId, BigDecimal permissionId) {
		this.userId = userId;
		this.permissionId = permissionId;
	}

	@Column(name = "USERID")
	public BigDecimal getUserId() {
		return userId;
	}

	public void setUserId(BigDecimal userId) {
		this.userId = userId;
	}

	@Column(name = "PERMISSIONID")
	public BigDecimal getPermissionId() {
		return permissionId;
	}

	public void setPermissionId(BigDecimal permissionId) {
		this.permissionId = permissionId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((permissionId == null) ? 0 : permissionId.hashCode());
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UserPermissionPk other = (UserPermissionPk) obj;
		if (permissionId == null) {
			if (other.permissionId != null)
				return false;
		} else if (!permissionId.equals(other.permissionId))
			return false;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}

}
